package mock.servicesdirectory.organisations.dao.daoimpl;

import java.util.List;

import mock.servicesdirectory.common.entities.Directorate;
import mock.servicesdirectory.organisations.dao.daointerface.DirectorateDAO;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class DirectorateDAOImpl extends HibernateDaoSupport implements DirectorateDAO{
	
	// Get all Directorate
	@SuppressWarnings("unchecked")
	@Override
	public List<Directorate> getDirectorate() {
		// TODO Auto-generated method stub
		// Query to get all directorate
		
		return getHibernateTemplate().find("from Directorate");
	}

	// Get directorate lie with an organisation	
	@SuppressWarnings("unchecked")
	@Override
	public List<Directorate> getDirectorate(int orgid) {
		// TODO Auto-generated method stub
		// Query
		String sql;
		List<Directorate> directorate;
		sql = "from Directorate where OrgId = :orgid";
		Session session = this.getSession();
		Query query = session.createQuery(sql);
		query.setParameter("orgid", orgid);			
		directorate = query.list();
		return directorate ;
	}
	
	// Method to get all directorate where name start with a flag
	/*
	 * flag = 1 . Name start with a digit 0-9
	 * flag = 2 . Name start with A, B, C, D ,E
	 * flag = 3 . Name start with F, G, H, I, J
	 * flag = 4 . Name start with K, L, M, N
	 * flag = 5 . Name start with 0, P, Q , R
	 * flag = 6 . Name start with S, T, U , V
	 * flag = 7 . Name start with W, Y, Z
	 */
	@Override
	public List<Directorate> getDirectorate(int orgid, int flag) {
		// TODO Auto-generated method stub
		// Query 
		
		return null;
	}
	
}
